package seleniumUnit;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;

public class robotKeyboard {
	
	public static void main(String[] args) {
//		try {
//			Thread.sleep(10000);
//		} catch (InterruptedException e1) {
//			e1.printStackTrace();
//		}
//		File file=new File("C:/Users/daijun/Desktop/sku");
//		String path = file.getAbsolutePath();
//		System.out.println(path);
//		Screen s=new Screen();
//		System.out.println("start Test");
//		try {
//			s.doubleClick(path+"/10.png");
//		} catch (FindFailed e) {
//			e.printStackTrace();
//		}
//		System.out.println("end Test");
	}
	
	public static void keyboardOperate(String filePath) {
		//Ctrl+c 复制文件
		StringSelection ss=new StringSelection(filePath);
		Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
		
		Robot robot;
		try {
			robot = new java.awt.Robot();
			//Ctrl+v
			robot.keyPress(KeyEvent.VK_CONTROL);
			robot.keyPress(KeyEvent.VK_V);
			robot.keyRelease(KeyEvent.VK_V);
			robot.keyRelease(KeyEvent.VK_CONTROL);
			
			//enter
			robot.keyPress(KeyEvent.VK_ENTER);
			robot.keyRelease(KeyEvent.VK_ENTER);
		} catch (AWTException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

		
	}
}
